<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/static/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#ruid").blur(function () {
                $.post("/rstore/queryruid","ruid="+this.value,function (data) {
                    if (data == "1") {
                        $("#Msg").html("入库单号已存在").css("color","red");
                    }else {
                        $("#Msg").html("");
                    }
                })
            })
            $("#submit").click(function () {
                if ($("#ruid").val()==null||$("#ruid").val().trim().length==0){
                    $("#Msg").html("入库单号不能为空").css("color","red");
                    return ;
                }else {
                    $("#submit").submit();
                }
            })
            $("#num").blur(function () {
                var value = document.getElementById("num").value;
                var reg = /^[1-9]\d*$|^0$/;
                if (reg.test(value) == true && value>0) {
                    $("#numMsg").html("");
                } else {
                    $("#numMsg").html("请输入正整数").css("color", "red");
                }
            })
        })

    </script>
</head>
<body>
<form action="/rstore/add" method="post">
    <div>
        <table style="background-color: white">
            <tr>
                <td>入库单号</td><td><input type="text" name="ruid" id="ruid"><label id="Msg"></label></td>
            </tr>
            <tr>
                <td>源订单ID</td><td><input type="text" name="oid" required></td>
            </tr>
            <tr>
                <td>类型</td>
                <td>
                    <select name="rtype">
                        <option value="">请选择</option>
                        <option value="1">采购入库</option>
                        <option value="2">退货入库</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>供应商/客户名称</td><td><input type="text" name="rname" required></td>
            </tr>
            <tr>
                <td>入库仓库</td>
                <td>
                    <select id="dept" name="gnid">
                        <option value="">请选择</option>
                        <#list gnumbers as g>
                            <option value="${g.gnid}">${g.gname}</option>
                        </#list>
                    </select>
                </td>
            </tr>
            <tr>
                <td>经办人</td><td><input type="text" name="storeadmin" required><input type="hidden" name="state" value="3"></td>
            </tr>
            <tr>
                <td>商品名称：</td>
                <td>
                    <select name="cid">
                        <option value="">请选择</option>
                        <#list commodities as c>
                            <option value="${c.id}">${c.commName}</option>
                        </#list>
                    </select>
                </td>
            </tr>
            <tr>
                <td>添加数目</td>
                <td>
                    <input type="text" name="number" id="num" required>
                    <label id="numMsg"></label>
                </td>
            </tr>
        </table>
    </div>
    <div>
        <table>
            <tr>
                <td><input type="submit" id="submit" value="提交"></td>
                <td><input type="reset" ></td>
            </tr>
        </table>
    </div>
</form>
</body>
</html>